//
//  TranManagerVC.m
//  ReceiptDelivery
//
//  Created by 吕晶 on 2020/7/27.
//  Copyright © 2020 吕晶. All rights reserved.
//

#import "TranManagerVC.h"
#import "TranManager_NavBar.h"
#import "TranManagerCell.h"
#import "WCQRCodeScanningVC.h"
#import "BackBoxManagerVC.h"
#import "AddLadingBillVC.h"
#import "AddBackBoxPlanListVC.h"
#import "LadingBillViewController.h"
#import "HeTongManagerVC.h"
#import "AddYunDanOneVC.h"
#import "GoodManagerMainVC.h"
#import "MyShipmentMainVC.h"
#import "MyCollectMainVC.h"
#import "BillAddPackageListVC.h"
#import "ScanBoxModel.h"
#import "ScanZhuangXiangVC.h"

@interface TranManagerVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) TranManager_NavBar *navBar;
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation TranManagerVC

-(TranManager_NavBar *)navBar {
    if (!_navBar) {
        _navBar = [[TranManager_NavBar alloc] initWithFrame:CGRectMake(0, 0, ScreenW, StatusBarHeight + 185)];
        __weak_self;
//        _navBar.tiHuoPlanBlock = ^{
//            //新建提货计划
//            AddLadingBillVC *vc = [AddLadingBillVC new];
//            vc.hidesBottomBarWhenPushed = YES;
//            [weakself.rt_navigationController pushViewController:vc animated:YES];
//        };
//        _navBar.fanXiangPlanBlock = ^{
//            //新建返箱计划
//            AddBackBoxPlanListVC *vc = [AddBackBoxPlanListVC new];
//            vc.hidesBottomBarWhenPushed = YES;
//            [weakself.rt_navigationController pushViewController:vc animated:YES];
//        };
//        _navBar.yunDanBlock = ^{
//            //新建运单
////            AddYunDanOneVC *vc = [AddYunDanOneVC new];
//            BillAddPackageListVC *vc = [BillAddPackageListVC new];
//            vc.hidesBottomBarWhenPushed = YES;
//            [weakself.rt_navigationController pushViewController:vc animated:YES];
//        };
        _navBar.woFaYunBlock = ^{
            //我发运的
            MyShipmentMainVC *vc = [MyShipmentMainVC new];
            vc.hidesBottomBarWhenPushed = YES;
            [weakself.rt_navigationController pushViewController:vc animated:YES];
        };
        _navBar.woShouBlock = ^{
            //我收的
            MyCollectMainVC *vc = [MyCollectMainVC new];
            vc.hidesBottomBarWhenPushed = YES;
            [weakself.rt_navigationController pushViewController:vc animated:YES];
        };
    }
    return _navBar;
}

-(UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenW, NaviHeight + 111)];
        _bgView.backgroundColor = Color_ThemeColor;
        [_bgView setRadianLayer:DXRadianDirectionBottom Radius:20];
    }
    return _bgView;
}

-(UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.navBar.nim_bottom, ScreenW, ScreenH - TabbarHeight - self.navBar.nim_bottom)];
        _tableView.backgroundColor = HexColor(0xffffff);
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = YES;
    self.view.backgroundColor = HexColor(0xffffff);
    [self.view addSubview:self.bgView];
    [self.view addSubview:self.navBar];
    [self.view addSubview:self.tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TranManagerCell *cell = [TranManagerCell TranManagerCellWithTableView:tableView];
    __weak_self;
    cell.saoMaBlock = ^{
        //扫码装箱
        WCQRCodeScanningVC *vc = [WCQRCodeScanningVC new];
        vc.hidesBottomBarWhenPushed = YES;
        vc.returnBlock = ^(id dic) {
            ScanBoxModel *model = [ScanBoxModel mj_objectWithKeyValues:dic];
            if (model.type.length) {
                ScanZhuangXiangVC *vc = [ScanZhuangXiangVC new];
                vc.boxModel = model;
                vc.hidesBottomBarWhenPushed = YES;
                [weakself.rt_navigationController pushViewController:vc animated:YES];
            }
        };
        [weakself.rt_navigationController pushViewController:vc animated:YES];
    };
    cell.yunDanAddBlock = ^{
        //运单添加包装
        BillAddPackageListVC *vc = [BillAddPackageListVC new];
        vc.hidesBottomBarWhenPushed = YES;
        [weakself.rt_navigationController pushViewController:vc animated:YES];
    };
    cell.heTongBlock = ^{
        //合同管理
        HeTongManagerVC *vc = [HeTongManagerVC new];
        vc.hidesBottomBarWhenPushed = YES;
        [weakself.rt_navigationController pushViewController:vc animated:YES];
    };
//    cell.woFaYunBlock = ^{
//        //我发运的
//        MyShipmentMainVC *vc = [MyShipmentMainVC new];
//        vc.hidesBottomBarWhenPushed = YES;
//        [weakself.rt_navigationController pushViewController:vc animated:YES];
//    };
//    cell.woShouBlock = ^{
//        //我收的
//        MyCollectMainVC *vc = [MyCollectMainVC new];
//        vc.hidesBottomBarWhenPushed = YES;
//        [weakself.rt_navigationController pushViewController:vc animated:YES];
//    };
//    cell.tiBillManagerBlock = ^{
//        //提单管理
//        LadingBillViewController *vc = [LadingBillViewController new];
//        vc.hidesBottomBarWhenPushed = YES;
//        [weakself.rt_navigationController pushViewController:vc animated:YES];
//    };
//    cell.scanInstallBoxBlock = ^{
//        //扫码装箱
//        WCQRCodeScanningVC *vc = [WCQRCodeScanningVC new];
//        vc.hidesBottomBarWhenPushed = YES;
//        vc.returnBlock = ^(id dic) {
//            ScanBoxModel *model = [ScanBoxModel mj_objectWithKeyValues:dic];
//            if (model.type.length) {
//                ScanZhuangXiangVC *vc = [ScanZhuangXiangVC new];
//                vc.boxModel = model;
//                vc.hidesBottomBarWhenPushed = YES;
//                [weakself.rt_navigationController pushViewController:vc animated:YES];
//            }
//        };
//        [weakself.rt_navigationController pushViewController:vc animated:YES];
//    };
//    cell.backBoxBlock = ^{
//        //返箱管理
//        BackBoxManagerVC *vc = [BackBoxManagerVC new];
//        vc.hidesBottomBarWhenPushed = YES;
//        [weakself.rt_navigationController pushViewController:vc animated:YES];
//    };
//    cell.heTongBlock = ^{
//        //合同管理
//        HeTongManagerVC *vc = [HeTongManagerVC new];
//        vc.hidesBottomBarWhenPushed = YES;
//        [weakself.rt_navigationController pushViewController:vc animated:YES];
//    };
//    cell.goodManagerBlock = ^{
//        //货物管理
//        GoodManagerMainVC *vc = [GoodManagerMainVC new];
//        vc.hidesBottomBarWhenPushed = YES;
//        [weakself.rt_navigationController pushViewController:vc animated:YES];
//    };
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    TranManagerCell *cell = [TranManagerCell TranManagerCellWithTableView:tableView];
    return cell.height;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
